<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">

            <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                            <div class="ibox-title">
                                    <h5>{{.title}}</h5>
                            </div>
                            <div class="ibox-content">
                                <button onclick='javascript:window.location.href="{{str2html .DefaultUrl}}";' class="btn btn-success" type="button"><span class="bold">返回列表</span>
                                </button>

                            </div>
                            <div class="ibox-content">
                                    <form class="form-horizontal m-t" id="Form1" method="post">
                                            <div class="form-group">
                                                    <label class="col-sm-3 control-label">用户名：</label>
                                                    <div class="col-sm-8">
                                                            <input id="username" name="username" class="form-control" type="text" placeholder="用户名" required="">
                                                    </div>
                                            </div>
                                            <div class="form-group">
                                                    <label class="col-sm-3 control-label">真实姓名：</label>
                                                    <div class="col-sm-8">
                                                        <input id="realyname" name="realyname" class="form-control" type="text" placeholder="真实姓名">
                                                    </div>
                                            </div>
                                            <div class="form-group">
                                                    <label class="col-sm-3 control-label">密码：</label>
                                                    <div class="col-sm-8">
                                                        <input id="password" name="password" class="form-control" type="password" placeholder="密码" required="">
                                                    </div>
                                            </div>
                                            
                                            <div class="form-group">
                                                    <label class="col-sm-3 control-label">Email：</label>
                                                    <div class="col-sm-8">
                                                        <input id="email" name="email" class="form-control" type="email" placeholder="Email" required="">
                                                    </div>
                                            </div>
                                            <div class="form-group">
                                                    <label class="col-sm-3 control-label">Note：</label>
                                                    <div class="col-sm-8">
                                                        <textarea rows="5" id="note" class="form-control" name="note"></textarea>
                                                    </div>
                                            </div>


                                            <div class="form-group">
                                                    <div class="col-sm-8 col-sm-offset-3">
                                                            <button class="btn btn-primary" type="submit">提交</button>
                                                    </div>
                                            </div>
                                    </form>
                            </div>
                    </div>
            </div>
    </div>

</div>
<script>

function FUser(tableName) {
    'use strict';
    // this.AddSaveUrl = '{{.AddSaveUrl}}';
    this.AddSaveUrl = '{{.AddSaveUrl}}';
    this.FormID = "#Form1"

    this.Init();
}

FUser.prototype.Init = function () {
    $(this.FormID).submit(this.Form_OnSubmit);
}

FUser.prototype.Form_OnSubmit = function () {
    var obj = User;
    data = {
        "username":$("#username").val(),
        "realyname":$("#realyname").val(),
        "password":$("#password").val(),
        "email":$("#email").val(),
        "note":$("#note").val()
    }
    // 显示 mark 层
	var loading = layer.load(0, {
		shade: [0.1,'#000']
    });
    
    $.ajax({
        url: obj.AddSaveUrl,
        data: data,
        type: 'post',
        cache: false,
        dataType: 'json',
        success: function (data) {
            layer.close(loading);
            if(data.code!=0){
				swal(data.title,data.msg,"error");
			}else{
				swal("操作成功",data.msg,"success").then((value) => {
					window.location.href = window.location.href;
				});
			}
            console.log(data);
        },
        error: function () { console.log('异常请求') }
    });
    return false;
}

/**
* 页面初始化
*/
$(document).ready(function () {
   if (typeof window.User == 'undefined') {
       window.User = new FUser();
   }
});
</script>